<!DOCTYPE html>
<#assign secSelect = JspTaglibs["http://www.casic304.cn/secSelect"] />
<html>
<head>
    <meta charset="utf-8">
    <title>飞行试验奖惩项目管理基本信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body class="listBody">

<div class="qbdms-bodyDiv">
    <div class="layui-table-view-body qbdms-add-view-body">
        <form class="formPreview layui-form"  requrl="${ctx}/qbdms/wFlightRewardsProject/get" lay-filter="wFlightRewardsProjectDataForm">

            <div class="qbdms-formTitle" style="border-bottom: 1px solid #E5F0FF">飞行试验奖惩项目信息 <i  class="qbdms-returnOn closeWindow">返回</i></div>
            <div class="qbdms-formBody">
                <div class="dragInfo temSpace" id="tbxx"></div>
                <div class="layui-row">
                    <div class="" style="display: none;">
                        <label class="layui-form-label qbdms-label" title="主键">主键</label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" name="id"  placeholder="请输入" fieldname="id"
                                   autocomplete="off" class="layui-input" maxlength="50">
                        </div>
                    </div>

                    <div class="qbdms-oneForm  ">
                        <label class="layui-form-label qbdms-label" title="飞行试验名称">飞行试验名称<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" name="flighttestname"  placeholder="请输入"
                                   autocomplete="off" class="layui-input" maxlength="50" fieldname="flighttestname"
                                   lay-verify="required" lay-reqtext="飞行试验名称是必填项" />
                        </div>
                    </div>
                    <div class="qbdms-oneForm  ">
                        <label class="layui-form-label qbdms-label" title="密级">密级<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <@secSelect.sec_select required=true data_src=1 name="secret"/>
                        </div>
                    </div>
                    <div class="qbdms-oneForm  ">
                        <label class="layui-form-label qbdms-label" title="年度">年度<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" name="year"  placeholder="请输入"
                                   autocomplete="off" id="year" class="layui-input dateTimeFiled time-init year" maxlength="50" fieldname="year"
                                   lay-verify="required" lay-reqtext="年度是必填项" readonly/>
                        </div>
                    </div>
                    <div class="qbdms-oneForm  ">
                        <label class="layui-form-label qbdms-label" title="型号名称">型号名称<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <select name="modelname" lay-verify="required" autocomplete="off" lay-search="" lay-reqtext="型号名称为必填项">
                                <option value=""></option>
                            </select>
                        </div>
                    </div>
                    <div class="qbdms-oneForm  ">
                        <label class="layui-form-label qbdms-label" title="总体单位名称">总体单位名称<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <select name="totalityunitcode" id="totalityunitcodeId" lay-filter="totalityunitcode" lay-verify="required" lay-search="" lay-reqtext="总体单位名称为必填项">
                                <option></option>
                            </select>
                            <input name="totalityunitname" type="text" hidden>
                        </div>
                    </div>
                    <div class="qbdms-oneForm  ">
                        <label class="layui-form-label qbdms-label" title="项目类型">项目类型<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <select name="projecttype" lay-verify="required" lay-reqtext="项目类型为必填项">
                                <option></option>
                            </select>
                        </div>
                    </div>
                    <div class="qbdms-oneForm  ">
                        <label class="layui-form-label qbdms-label" title="项目类别">项目类别<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <select name="projectcategory" lay-verify="required" lay-reqtext="项目类别为必填项">
                                <option></option>
                            </select>
                        </div>
                    </div>
                    <div class="qbdms-oneForm  ">
                        <label class="layui-form-label qbdms-label" title="项目阶段">项目阶段<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <select name="projectstage" lay-verify="required" lay-reqtext="项目阶段为必填项">
                                <option></option>
                            </select>
                        </div>
                    </div>
                    <div class="qbdms-oneForm  ">
                        <label class="layui-form-label qbdms-label" title="奖励额度(万元)">奖励额度(万元)<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" name="bonusgiven"  placeholder="请输入" lay-verify="required|money"
                                   autocomplete="off" class="layui-input" maxlength="12" fieldname="bonusgiven" lay-reqtext="奖励额度(万元)为必填项"/>
                        </div>
                    </div>
                    <div class="qbdms-oneForm  ">
                        <label class="layui-form-label qbdms-label" title="处罚额度(万元)">处罚额度(万元)<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" name="penaltyamount"  placeholder="请输入" lay-verify="required|money"
                                   autocomplete="off" class="layui-input" maxlength="12" fieldname="penaltyamount" lay-reqtext="处罚额度(万元)为必填项"/>
                        </div>
                    </div>
                    <div class="qbdms-oneForm  ">
                        <label class="layui-form-label qbdms-label" title="产品价格(万元)">产品价格(万元)<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" name="productprice"  placeholder="请输入" lay-verify="required|money"
                                   autocomplete="off" class="layui-input" maxlength="12" fieldname="productprice" lay-reqtext="产品价格(万元)为必填项"/>
                        </div>
                    </div>
                    <div class="qbdms-oneForm  ">
                        <label class="layui-form-label qbdms-label" title="项目主管部门">项目主管部门<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <select name="projectdepartment" lay-verify="required" lay-reqtext="项目主管部门为必填项">
                                <option></option>
                            </select>
                        </div>
                    </div>
                    <div class="qbdms-oneForm  ">
                        <label class="layui-form-label qbdms-label" title="是否临时">是否临时</label>
                        <div class="layui-input-block qbdms-input">
                            <select name="istemp">
                                <option value="是">是</option>
                                <option value="否">否</option>
                            </select>
                        </div>
                    </div>

                    <div class="qbdms-textarea  ">
                        <label class="layui-form-label qbdms-label">附件</label>
                        <div class="layui-input-block qbdms-input">
                            <div class="doNotDelThisDiv layui-input-inline">
                                <div class="uploadFileCont">
                                    <button type="button"
                                            class="layui-btn fileUpload qbdms-fileUp iconfont iconupload"
                                            id="accessoryfileList"> 上传附件</button><i class="qbdms-fileUpText">支持单个附件上传，附件格式：doc  docx    pdf   xls    xlsx，文件大小限制不超过100M</i>
                                    <input type="text" id="accessory" class="uploadInput"
                                           name="accessory" fieldname="accessory" style="display: none">
                                    <div class="uploadFileList" fileUploadName="accessory"></div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="qbdms-textarea  ">
                        <label class="layui-form-label qbdms-label" title="备注">备注</label>
                        <div class="layui-input-block qbdms-input">
                            <textarea rows="2" name="remark"  placeholder="请输入"
                                      autocomplete="off" class="layui-textarea"
                                      maxlength="500" fieldname="remark"></textarea>
                        </div>
                    </div>
                </div>
            </div>

            <p class="qbdms-SubTableTitle"><span>奖惩金额分配信息</span></p>
            <div class="qbdms-tableDiv">
                <a modetype="2" class="addFormTr1"
                   id="add"><i class="layui-icon layui-icon-addition"></i>新增</a>
                <table class="qbdms-temTable wRewardsMoneyAllocationList subFormTable"
                       id="wRewardsMoneyAllocationList" style="min-width: 1360px;">
                    <tbody>
                    <tr class="temSpace qbdms-temTable-thead">
                        <td class="temSpace" style="width: 30px;">
                            序号
                        </td>
                        <td class="temSpace subDialogShowState" style="width: 120px">
                            奖惩单位名称<span style="color: red;">*</span>
                        </td>
                        <td class="temSpace subDialogShowState" style="width: 120px">
                            单位类别<span style="color: red;">*</span>
                        </td>
                        <td class="temSpace subDialogShowState" style="width: 120px">
                            配套关系级别
                        </td>
                        <td class="temSpace subDialogShowState" style="width: 120px">
                            配套产品名称
                        </td>
                        <td class="temSpace subDialogShowState" style="width: 120px">
                            奖惩分配比例<span style="color: red;">*</span>
                        </td>
                        <td class="temSpace qbdms-subOptState">
                            管理
                        </td>
                    </tr>
                    <tr class="temSpace subContTem">
                        <td class="temSpace qbdms-temTable-seNumber">
                            <div class="temTag">0</div>
                        </td>
                        <td class="temSpace qbdms-temTable-td">
                            <select name="s:wRewardsMoneyAllocationList:rewardsUnitName" lay-filter="s:wRewardsMoneyAllocationList:rewardsUnitName" requiredFlag="required" lay-reqtext="奖惩单位名称为必填项">
                                <option></option>
                            </select>
                            <input type="hidden" name="s:wRewardsMoneyAllocationList:rewardsUnitCodeName"/>
                        </td>
                        <td class="temSpace qbdms-temTable-td">
                            <select name="s:wRewardsMoneyAllocationList:unitCategory" requiredFlag="required" lay-reqtext="单位类别为必填项">
                                <option></option>
                            </select>
                        </td>
                        <td class="temSpace qbdms-temTable-td">
                            <select name="s:wRewardsMoneyAllocationList:supportingRelationshipLevel" class="supportingRelationshipLevel">
                                <option></option>
                            </select>
                        </td>
                        <td class="temSpace qbdms-temTable-td">
                            <input type="text" placeholder="请输入"
                                   autocomplete="off"
                                   class="layui-input textInput supportingProductsName"
                                   name="s:wRewardsMoneyAllocationList:supportingProductsName"
                                   maxlength="50">
                        </td>
                        <td class="temSpace qbdms-temTable-td">
                            <input type="text" placeholder="请输入"
                                   autocomplete="off"
                                   class="layui-input textInput"
                                   name="s:wRewardsMoneyAllocationList:rewardsAllocationProportion"
                                   maxlength="50" requiredFlag="required|money" lay-reqtext="奖惩分配比例为必填项" style="width: 90%;display: inline"><span style="line-height: 38px;">%</span>
                        </td>
                        <td class="temSpace qbdms-subOptState">
                            <a class="subDeleteTr RightBtn">删除</a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>

            <div class="layui-form-item btnformItem">
                <p>
                    <span id="hideAndShow" style="display: none;">
                        <a lay-submit lay-filter="wQbdQualityRewardsMessage" class="layui-btn btn-n privateSubmit qbdms-oneBtn"
                           requrl="${ctx}/qbdms/wFlightRewardsProject/save">提交</a>
                    </span>
                    <button type="reset" id="closeWindow" style="margin-left: 10px;"
                            class="layui-btn layui-btn-sm btn-save qbdms-oneBtnLine">取消
                    </button>
                </p>
            </div>
        </form>
    </div>
</div>

<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'setter', 'layer',  'form', 'table',  'propsHandle', 'common', 'laydate', 'jquery','upload','publicMethods', 'qbdmsForm'], function () {

        // -----常量声明----------
        var $ = layui.jquery,
            laydate = layui.laydate,
            setter = layui.setter,  // 配置信息
            layer = layui.layer,
            upload = layui.upload,
            common = layui.common,
            publicMethods = layui.publicMethods,
            propsHandle = layui.propsHandle,
            form = layui.qbdmsForm,
            formId = '${formDefId}' || '',
            defProps = {
                //viewMould: 'form/formDef/view/formDesign/moulds/', // 组件模块 存放文件 *****
                viewMould: 'moulds/', // 组件模块 存放文件 *****
                formAreaInfo: 'html',
                temDate: '.temDate',
                uploadFileBtn: '.uploadFileBtn',
                uploadImgBtn: '.uploadImgBtn',
                richTextArea: '.richTextArea',
                selectInput: '.selectInput',
                radioOptionCont: '.radioOptionCont',
                dataLexiTree: '.dataLexiTree',
                selectorBtn: '.selectorBtn'
            },
            temQuery = new propsHandle();  // 实例化模板功能部分

        //- 添加表单验证规则 开始 ---------------------------------------------------------------------
        form.verify({
            integer: [/^[+]{0,1}(\d+)$/,'请输入正整数'],
            money: [/^((0{1}\.\d{1,2})|([1-9]\d*\.{1}\d{1,2})|([1-9]+\d*))$/,'请输入正整数和两位小数的数据'],
            length100:[/^.{0,100}$/,'输入字符数不能超过100'],
            length2000:[/^.{0,2000}$/,'输入字符数不能超过2000'],
            fileRequired:[/[\S]+/,"没有上传对应附件"]
        });
        //- 添加表单验证规则 结束 ---------------------------------------------------------------------

//        $("[lay-verify='required']").attr("lay-verify", "");
        laydate.render({
            elem: '#year'
            , type: 'year'
            , trigger: 'click'
        });

        $(".subContTem").hide();

        var count = 1;
        $(document).on('click', '.addFormTr1', function () {
            count += 1;
            var modetype = $(this).attr('modetype'),
                copyObj = $(this).parent().children('.subFormTable'),
                copyHtm = copyObj.find('tr').eq(1);
            if (modetype === '2') {
                //在这里做一个转换，控制子表隐藏行的必填
                var copyHtmlStr = copyHtm.html();
                copyHtmlStr = copyHtmlStr.replace(/requiredflag/g, "lay-verify");
                // 表格
                copyObj.append('<tr class="temSpace">' + copyHtmlStr + '</tr>');
                var trArr = copyObj.find('tr');
                trArr.eq(trArr.length - 1).find('td').eq(0).find('.temTag').html(trArr.length - 2);

                trArr.eq(trArr.length - 1).find('[isinit="1"]').each(function (i, item) {
                    $(item).attr('isinit', '2');
                });
                if (trArr.length > 3) {
                    trArr.eq(trArr.length - 1).find('[type=radio]').each(function (i, item) {
                        $(item).attr('name', (trArr.eq(1).find('[type=radio]').eq(i).attr('name')) + '_' + (trArr.length - 2))
                    });
                }
                temQuery.initTemEvent(defProps, serverPath, setter);
            } else if (modetype === '1') {
                // updateTr(copyObj, copyHtm);
            }
            form.render();
            lay('.datetime').each(function () {
                laydate.render({
                    elem: this
                    , type: 'year'
                    , trigger: 'click'
                });
            });
            $(".datetime").removeAttr("lay-key");
            publicMethods.bottomFixd()
        });

        /**-------数据字典初始化-------**/
        $().ready(function () {
            // 型号名称
            var xhmcList = eval('${xhmcList}');
            var xhmcHtml = "";
            $.each(xhmcList, function (index, obj) {
                xhmcHtml += "  <option value='" + obj.itemName + "'>" + obj.itemName + "</option>";
            });
            $("select[name='modelname']").append(xhmcHtml);

            // 项目阶段
            var xmjdList = eval('${xmjdList}');
            var xmjdHtml = "";
            $.each(xmjdList, function (index, obj) {
                xmjdHtml += "  <option value='" + obj.itemValue + "'>" + obj.itemName + "</option>";
            });
            $("select[name='projectstage']").append(xmjdHtml);

            // 项目类型
            var xmlxList = eval('${xmlxList}');
            var xmlxHtml = "";
            $.each(xmlxList, function (index, obj) {
                xmlxHtml += "  <option value='" + obj.itemValue + "'>" + obj.itemName + "</option>";
            });
            $("select[name='projecttype']").append(xmlxHtml);

            // 项目类别
            var xmlbList = eval('${xmlbList}');
            var xmlbHtml = "";
            $.each(xmlbList, function (index, obj) {
                xmlbHtml += "  <option value='" + obj.itemValue + "'>" + obj.itemName + "</option>";
            });
            $("select[name='projectcategory']").append(xmlbHtml);

            // 项目主管部门
            var zgbmList = eval('${zgbmList}');
            var zgbmHtml = "";
            $.each(zgbmList, function (index, obj) {
                zgbmHtml += "  <option value='" + obj.itemValue + "'>" + obj.itemName + "</option>";
            });
            $("select[name='projectdepartment']").append(zgbmHtml);


            // 单位类别
            var dwlbList = eval('${dwlbList}');
            var dwlbHtml = "";
            $.each(dwlbList, function (index, obj) {
                dwlbHtml += "  <option value='" + obj.itemValue + "'>" + obj.itemName + "</option>";
            });
            $("select[name='s:wRewardsMoneyAllocationList:unitCategory']").append(dwlbHtml);

            //总体单位名称
            var ztdwmcList = eval('${ztdwmcList}');
            var ztdwmcHtml = "";
            $.each(ztdwmcList, function (index, obj) {
                ztdwmcHtml += "  <option value='" + obj.itemValue + "'>" + obj.itemName + "</option>";
            });
            $("select[name='totalityunitcode']").append(ztdwmcHtml);
            $("select[name='s:wRewardsMoneyAllocationList:rewardsUnitName']").append(ztdwmcHtml);

            // 配套关系级别
            var ptgxjbList = eval('${ptgxjbList}');
            var ptgxjbHtml = "";
            $.each(ptgxjbList, function (index, obj) {
                ptgxjbHtml += "  <option value='" + obj.itemValue + "'>" + obj.itemName + "</option>";
            });
            $("select[name='s:wRewardsMoneyAllocationList:supportingRelationshipLevel']").append(ptgxjbHtml);

        });

        //下载附件
        window.downFile = function (obj) {
            var fileId = $(obj).parents("span").attr("fileId");
            window.location.href = serverPath.qbdmsPath + setter.extendLinkPath + "attachFile/download?fileId=" + fileId;
        }

        // 删除
        $(document).on('click', '.deleteFile', function () {
            $(".uploadFileList").each(function (i,v) {
                common.constructFileStr(v)
            });
        });

        // 初始化模板功能
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });

        // 子表初始化事件
        temQuery.initSubEvent(defProps, serverPath, setter);
        laydate.render({
            elem: '.temDate'
        });

        //关闭当前页面
        $("#closeWindow,.closeWindow").click(function () {
            window.location.href = '${ctx}/qbdms/wFlightRewardsProject/view/list';
        });

        var secSelect = '<@secSelect.sec_select data_src=1 hasBlank=false/>'
        common.uploadfun(".fileUpload",{
            acceptMime:'application/pdf,application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document',
            exts:'doc|docx|pdf|xls|xlsx',
            secSelect:secSelect,
            isSub:false,
            upLoadSize: 102400
        })

        var runId = "${runId}";
        if(runId == null || runId == ''){
            $("#hideAndShow").show();
        }

        var id = "${id}";
        if (id == null || id === '') {
            $("#tbxx").html("<span class='qbdms-TBinformation'>填报信息:</span><span class='qbdms-TBinformationText'>【${filldept}   | ${fillman}  | ${filldate}】</span>");
        }

        common.updateForm({
            name:'wFlightRewardsProjectDataForm',
            idValue:"${id}",
            primary:"id",
            beforeSubmitFun:function (data) {

                data.field["year"] = new Date($("input[name='year']").val())
                var selectMaxVal = 0;
                var formSecretVal = $("[name='secret']").val();
                $(".fileSecLevel select").each(function () {
                    selectMaxVal = selectMaxVal >= $(this).val() ? selectMaxVal : $(this).val();
                });

                if (selectMaxVal > formSecretVal) {
                    layer.msg('附件密级不能高于表单密级。', {icon: 5});
                    return false;
                }
                //- 附件密级不能高于表单密级 结束 ------------------------------------------------------
                $(".uploadFileList").each(function (i,v) {
                    common.constructFileStr(v)
                });
                //- 子表数据 开始 ------------------------------------------------------
                var sub = [];
                var subData = [];
                $('table.subFormTable').each(function () {
                    var table = {
                        tableName: $(this).attr('class').split(" ")[1],
                        fields: []
                    };
                    $(this).find('tr.temSpace').each(function (i, item) {    /*修复需要提交隐藏的行数据的bug*/
                        if (i > 1) {
                            var row = {};
                            var objRow = $(this);
                            $("input:text[name^='s:'],input[type='hidden'][name^='s:'],textarea[name^='s:'],select[name^='s:'],ul[name^='m:']", objRow).each(function () {
                                var name = $(this).attr('name').replace(/.*:/, '');
                                row[name] = $(this).val();
                            });
                            row["sort"] = i - 1;
                            table.fields.push(row);
                            subData.push(row)
                        }
                    });
                    data.field[table.tableName] = table.fields;
                });
                //- 子表数据 结束 ------------------------------------------------------

                var files=[];
                //整理上传附件的隐藏域，将提交的字符串转为json对象
                $(".uploadInput").each(function () {
                    var uploadName = $(this).attr("name");
                    if (!$(this).val()) {
                        return;
                    }
                    data.field[uploadName] = eval($(this).val());
                    files=files.concat(eval($(this).val()));
                });

                //判断奖惩单位名称是否重复
                var arr = [];

                for(var i=0;i<subData.length;i++){
                    arr.push(subData[i].rewardsUnitName);
                }

                //配套关系级别与奖惩分配比例的判断
                var isSupportingRelationshipLevel = false;
                var countProportion = 0;
                $.each(subData,function (i, value) {
                    if(subData[i].supportingRelationshipLevel == 'Ⅱ'){
                        if(subData[i].rewardsAllocationProportion > 20){
                            layer.msg("<p><i class='layui-icon layui-icon-close-fill'></i>错误提示</p ><span>配套关系级别为Ⅱ时,奖惩分配比例应小于百分之二十</span>", {
                                shift: 6,
                                skin: 'qbdms-verifyClass',
                            })
//                            layer.msg("配套关系级别为Ⅱ时,奖惩分配比例应小于百分之二十", {icon: 5});
                            isSupportingRelationshipLevel = true;
                        }
                    }else if(subData[i].supportingRelationshipLevel == 'Ⅲ'){
                        if(subData[i].rewardsAllocationProportion > 5){
                            layer.msg("<p><i class='layui-icon layui-icon-close-fill'></i>错误提示</p ><span>配套关系级别为Ⅲ时,奖惩分配比例应小于百分之五</span>", {
                                shift: 6,
                                skin: 'qbdms-verifyClass',
                            })
                            isSupportingRelationshipLevel = true;
                        }
                    }else{
                        if(subData[i].rewardsAllocationProportion > 100){
                            layer.msg("<p><i class='layui-icon layui-icon-close-fill'></i>错误提示</p ><span>配套关系级别为空时,奖惩分配比例不得大于百分之一百</span>", {
                                shift: 6,
                                skin: 'qbdms-verifyClass',
                            })
                            isSupportingRelationshipLevel = true;
                        }
                    }
                    countProportion = Number(countProportion) + Number(subData[i].rewardsAllocationProportion);
                    if(countProportion > 100){
                        layer.msg("<p><i class='layui-icon layui-icon-close-fill'></i>错误提示</p ><span>奖惩分配比例不得大于百分之一百</span>", {
                            shift: 6,
                            skin: 'qbdms-verifyClass',
                        })
                        isSupportingRelationshipLevel = true;
                    }
                });
                if(isSupportingRelationshipLevel){
                    return false;
                }

                var rewardsUnitNameIsExist = false;
                var s = arr.join(",") + ",";

                var arr1 = unique(arr);
                if(arr.length != arr1.length){
                    layer.msg("<p><i class='layui-icon layui-icon-close-fill'></i>错误提示</p ><span>重复的奖惩单位名称</span>", {
                        shift: 6,
                        skin: 'qbdms-verifyClass',
                    })
                    rewardsUnitNameIsExist = true;
                }

                if(rewardsUnitNameIsExist){
                    return false;
                }
                return common.setFileLevel(files);

            },
            getCallback:function (data) {
                var returnData = data.data;

                $("select[name='istemp']").val(returnData.istemp);
                $("select[name='istemp']").val(returnData.istemp);
                form.render("select");

                $("#tbxx").html("<span class='qbdms-TBinformation'>填报信息:</span>" +
                    "<span class='qbdms-TBinformationText'>【"+returnData.filldept+"   | "+returnData.fillman+"  | "+returnData.filldate+"】</span>");

                $('.uploadFileList').each(function () {
                    var fileUploadName = $(this).attr("fileUploadName");
                    var jsonFile = data.data[fileUploadName];
                    var files = eval(jsonFile);

                    if (files) {
                        for (var i = 0; i < files.length; i++) {
                            var fileLevel = files[i].fileLevel;
                            var fileLevelText = files[i].fileLevelText;
                            var fileSec = '<div class="fileSecLevel fileSecXg layui-input-inline">' + '<@secSelect.sec_select data_src=1 hasBlank=false/>' + "</div>";
                            var newStr = '<span class="file-id" style="margin-right: 20px;" fileId=' + files[i].fileId + ' fileLevelText="' + fileLevelText + '">' + fileSec + '<span class="file-name" title="点击下载文件" onclick="downFile(this)"><i class="iconfont data-iconcommon_fujian" style="margin-right: 5px"></i>' + files[i].fileName + '</span><i class="iconfont data-iconcommon_close deleteFile" ></i></span>';
                            // newStr = '<span class="file-id" style="margin-right: 20px;" fileId=' + files[i].fileId + '><span class="file-name" onclick="downFile(this)">' + files[i].fileName + '</span><i class="layui-icon layui-icon-delete deleteFile" ></i></span>';
                            $(this).html(newStr);
                            $(this).find("select:last").val(fileLevel);
                            // $(this).find("select:last").attr("disabled", "disabled");
                        }
                    }
                });

                //-修改页面 初始化子表 开始 ------------------------------------------

                $('table.subFormTable').each(function () {

                    var table = {
                        tableName: $(this).attr('class').split(" ")[1],
                        fields: []
                    };
                    table.fields = returnData[table.tableName];
                    if(table.fields.length > 0){
                        for (var i = 0, len = table.fields.length; i < len; i++) {
                            var dataRow = table.fields[i];
                            var temp = $("." + table.tableName).prev().click();
                            //这里有子表表头占一行，子表隐藏行占一行，所以取需要赋值的行时，需要temp=i+2
                            var domRow = $(this).find("tr.temSpace:eq(" + (i * 1 + 2) + ")");
                            $.each(dataRow, function (j, val) {
                                var domItem = domRow.find("[name$='" + j + "']");
                                if (domItem) {
                                    domItem.val(val);
                                }
                            });
                        }
                    }
                });

            },
            updateCallback: function (data) {
                if (publicMethods._filterRecord(data)) {
                    if ($(".privateSubmit")) {
                        $(".privateSubmit").attr("disabled", false).css("pointer-events", "auto");
                    }
                    layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'}, function (index) {
                        layer.close(index);
                        window.location.href = '${ctx}/qbdms/wFlightRewardsProject/view/list';
                    });
                } else {
                    layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                }
                return false;
            }
        });

        function unique(arr) {
            var array = [];
            for (var i = 0; i < arr.length; i++) {
                if (array .indexOf(arr[i]) === -1) {
                    array .push(arr[i])
                }
            }
            return array;
        }

        form.on('select(totalityunitcode)',function (data) {
            $("input[name='totalityunitname']").val(data.elem[data.elem.selectedIndex].text);
            $('table.subFormTable').each(function () {
                $(this).find('tr.temSpace').each(function (i, item) {
                    if (i > 1) {
                        var row = {};
                        var objRow = $(this);
                        $("input:text[name^='s:'],input[type='hidden'][name^='s:'],textarea[name^='s:'],select[name^='s:'],ul[name^='m:']", objRow).each(function () {
                            var name = $(this).attr('name');
                            var newName = $(this).attr('name').replace(/.*:/, '');
                            var value = handNumberData(this);
                            if(name === 's:wRewardsMoneyAllocationList:rewardsUnitName'){
                                if(value){
                                    $(this).closest("tr.temSpace").find("input[name='s:wRewardsMoneyAllocationList:supportingProductsName']").each(function (i, val) {
                                        if(data.value === value){
                                            $(this).removeAttr("requiredFlag");
                                            $(this).removeAttr("lay-verify");
                                        }else{
                                            $(this).attr("requiredFlag","required");
                                            $(this).attr("lay-verify","required");
                                        }
                                    });
                                    $(this).closest("tr.temSpace").find("select[name='s:wRewardsMoneyAllocationList:supportingRelationshipLevel']").each(function (i, val) {
                                        if(data.value === value){
                                            $(this).removeAttr("requiredFlag");
                                            $(this).removeAttr("lay-verify");
                                        }else{
                                            $(this).attr("requiredFlag","required");
                                            $(this).attr("lay-verify","required");
                                        }
                                    });
                                }
                            }

                            row[newName] = value;
                        });
                    }
                })
            })
        });

        form.on('select(s:wRewardsMoneyAllocationList:rewardsUnitName)', function(data){

            var rewardsUnitCodeValue = $(this).text();
            $(this).closest("tr.temSpace").find("input[name='s:wRewardsMoneyAllocationList:rewardsUnitCodeName']").each(function (i, value) {
                $(this).val(rewardsUnitCodeValue);
            })

            $(this).closest("tr.temSpace").find("input[name='s:wRewardsMoneyAllocationList:supportingProductsName']").each(function (i, value) {
                if(data.value === $("select[name='totalityunitcode']").val()){
                    $(this).removeAttr("requiredFlag");
                    $(this).removeAttr("lay-verify");
                    $(this).removeAttr("lay-reqtext");
                }else{
                    $(this).attr("requiredFlag","required");
                    $(this).attr("lay-verify","required");
                    $(this).attr("lay-reqtext","配套产品名称为必填项");
                }
            });
            $(this).closest("tr.temSpace").find("select[name='s:wRewardsMoneyAllocationList:supportingRelationshipLevel']").each(function (i, value) {
                if(data.value === $("select[name='totalityunitcode']").val()){
                    $(this).removeAttr("requiredFlag");
                    $(this).removeAttr("lay-verify");
                    $(this).removeAttr("lay-reqtext");
                }else{
                    $(this).attr("requiredFlag","required");
                    $(this).attr("lay-verify","required");
                    $(this).attr("lay-verify","required");
                    $(this).attr("lay-reqtext","配套关系级别为必填项");
                }
            });
        });

        function handNumberData(obj) {
            var value = $(obj).val();
            var showType = $(obj).attr("showtype");
            if (!showType) return value;
            try {
                showType = showType.replaceAll("'", "\"");
                var json = jQuery.parseJSON(showType);
                var coinvalue = json.coinValue;
                var isShowComdify = json.isShowComdify;
                if (coinvalue != null && coinvalue != '' && value.split(coinvalue) != -1) {
                    var ary = value.split(coinvalue);
                    value = ary.join("");
                }
                if (isShowComdify && value.split(",") != -1) {
                    var temp = value.split(",");
                    value = temp.join("");
                }
            } catch (err) {
            }
            return value;
        };
    });
</script>
</body>
</html>